<template>
  <view class="main_container">
		<!--  头部搜索栏 -->
		<!-- <view class="head">
			<view class="search_view">
				<input class="search" v-model="searchValue" placeholder="请输入关键字搜索" />
				<image src="http://113.142.144.25:9301/statics/appimg/icon_search_btn_new.png" 
					style="height: 30rpx;width:30rpx;padding: 20rpx;" @click="searchPolicy()"></image>
			</view>
		</view> -->
	  
		<!--导航栏-->
	<!-- 	<orderTabBar :tabList="tabList" @clickTabBar="clickTabBar" class="tab-bar" :show-line="true" /> -->
		<!--订单列表-->
		<scroll-view class="member_lsit" scroll-y="true" :style="'height:100%'" enable-flex  @scrolltolower="scrollToLower()" @scrolltoupper="updateOrderInfo()">
			<view v-show="item.xmmc" class="video_item" v-for="(item,index) in orderList" :key="index" @click="rencaiDetail(item.id)">
<!-- 				<image class="video_img" :src="item.image"></image> -->
				<view class="video_content">
					<view style="width: 100%;">
						<text class="video_title">{{item.xmmc}}</text>
						<text v-if="item.education" class="publicTime">学位：{{item.education}}</text>
						<text v-else class="publicTime">状态：{{formatterStatus(item.status)}}</text>
					</view>
					<view style="width: 100%; margin-top: 18rpx; font-size: 28rpx;float: left;">
						<text style="">毕业院校：{{item.graduateInstitutions?item.graduateInstitutions:'暂无'}}</text>
					</view>
					<view style="width: 100%; margin-top: 18rpx; font-size: 28rpx;float: left;">
						<text style="">单位名称：{{item.dwmc?item.dwmc:'暂无'}}</text>
						<text style="float: right;">联系人：{{item.lxr?item.lxr:'暂无'}}</text>
					</view>
					<view style="width: 100%; margin-top: 18rpx; font-size: 28rpx;float: left;">
						<text style="">项目内容：{{item.xmnr?item.xmnr:'暂无'}}</text>
					</view>
				</view>
			</view>
			<view class="no-data" v-if="orderList.length == 0" @click="getOrderList()">
				{{ noData }}
			</view>
		</scroll-view>
	  </view>
</template>

<script>
	import env from '@/utils/env';
	import orderTabBar from '@/wxcomponents/tab_bar.vue';
	import * as projectSearch from '@/api/projectSearch.js'
	import * as codeList from '@/utils/code.js'
	import * as dict from '@/api/system/dict/data.js'
	export default {
	  components: {
		orderTabBar,
	  },
	  data() {
		return {
		  showPage: false,
		  // 订单列表tab项
		  tabList: [{
			status: '',
			title: '全部'
		  },
		  {
		  	status: '1',
		  	title: '国家政策'
		  },
			{
			  status: '2',
			  title: '省级政策'
			},
			{
			  status: '3',
			  title: '市级政策'
			}
		  ],
		  // 当前选择tab项
		  currentIndex: 0,
		  // 当前查询状态
		  currentStatus: '',
		  // 订单列表高度
		  orderHeight: 0,
		  // 是否还有更多数据
		  noMoreData: {},
		  // 订单列表
		  orderList: [],
		  query:{
			  pageNum:1,
			  pageSize:10,
			  memberId:''
		  },
		  policylevel:'',
		  searchValue:'',
		  noData:'加载中',
		  total:0,
			statusList:[]
		}
	  },
	  onShow() {
		// let _this = this
		// _this.getOrderList()
		this.getDicts()
	  },
	  mounted() {
		this.getUser()
		let _this = this;
		uni.showLoading({
			title:"加载中。。。"
		})
		this.getOrderList()
	  },
	  methods: {
			formatterStatus(value){
				return this.statusList.find(item=>item.dictValue===value).dictLabel
			},
			getDicts(){
				dict.getDicts('shouli_status').then(res=>{
					this.statusList = res.data
				})
			},
		  getUser(id){
		  	var mystorage = uni.getStorageSync("userInfo") || []
		  	if(mystorage.login_user == null){
		  		uni.showToast({
		  			title:'请先登录！'
		  		})
		  		uni.navigateTo({
		  			url:'/subpages/pages/register/login_province'
		  		})
		  		uni.hideLoading()
		  		return
		  	}else{
		  		this.query.memberId = mystorage.login_user.member.id
		  	}
		  },
		// tab切换
		clickTabBar(index, status) {
		  this.currentIndex = index
		  this.currentStatus = status
		  this.orderList = [];
		  this.getOrderList()
		},
		// 加载订单列表
		getOrderList() {
			uni.showLoading({
				title:"加载中。。。"
			})
			this.noData = '加载中。。。'
			projectSearch.getMySearch(this.query).then((res)=>{
				if(res.errMsg='request:fail'){
					this.noData = '暂无数据，点击重试'
				}
				res.rows.forEach(v => {
					if(v.image != null){
						v.image = `${env.imgUrl}` + v.image
					}
					this.orderList.push(v)
				})
				this.total = res.total
				uni.hideLoading({});
				if(this.orderList.length == 0){
					this.noData = '暂无数据，点击重试'
				}
				
			});
			// if(this.orderList.length == 0){
			// 	this.noData = '暂无数据，点击重试'
			// }
		},
		// 更新order
		updateOrderInfo(index) {
			let _this = this
			this.query.pageNum = 1
			this.orderList = []
			_this.getOrderList()
		},
		// 滑到底部 加载更多
		scrollToLower() {
			if(this.orderList.length < this.total){
				this.query.pageNum = this.query.pageNum + 1;
				this.getOrderList();
			}else{
				uni.showToast({
					icon:'none',
					title:"没有更多数据"
				})
			}
		},
		rencaiDetail(id){
			uni.navigateTo({
				url:'/subpages/pages/projectSearch/index?id='+id
			})
		},
	  },
	  computed: {
			
	  }
	}
</script>

<style>
	.main_container{
		width: 100vw;
		height: 100vh;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
		background-color: #e3e3e3;
	}
	
	.member_lsit{
		height: fit-content;
		width: 100%;
		padding-top: 1rpx;
		padding-bottom: 1rpx;
		background-color: #e3e3e3;
	}
	
	.video_item {
		height: 240rpx;
		width: 95%;
		padding: 20rpx;
		margin: 20rpx auto;
		border-radius: 10rpx;
		background-color: #fff;
		box-shadow: 5rpx 0rpx 10rpx #e3e3e3;
	}
	
	.video_img {
		margin-top: 10rpx;
		height: 170rpx;
		width: 160rpx;
		border-radius: 50%;
		margin-left: 15rpx;
		float: left;
	}
	
	.video_content {
		float: right;
		width: 98%;
		height: 140rpx;
		margin-left: 15rpx;
		margin-right: 10rpx
	}
	
	.video_title {
		width: ;
		float: left;
		display: -webkit-box;
		font-size: 33rpx;
		font-weight: 700;
		margin-top: 15rpx;
		white-space: nowrap;
		overflow: hidden;
		white-space: nowrap;
		text-overflow:ellipsis;
		-webkit-box-orient: vertical; /*排列方式*/ 
		-webkit-line-clamp: 1; /*显示文本行数(这里控制多少行隐藏)*/
	}
	
	.publicTime {
		float:right;
		font-size: 23rpx;
		color:darkred;
		margin-top: 15rpx;
		
	}
	
	.devideline {
		float: left; 
		height: 0.3rpx;
		 width:100%;
		 background-color: #eeeeee;
		 margin-top: 15rpx;
		 margin-bottom: 15rpx;
	}
	.no-data {
		width: 100%;
		height: 300rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
		margin-top: 100rpx;
	}
</style>